package applet;

import java.applet.Applet;
import java.applet.AudioClip;
import java.io.File;
import java.net.MalformedURLException;

public class SoundPlaySimp {
	private AudioClip audioClip;
	private File audioFile;

	public void init() {
		audioFile = new File("D:\\Work\\workspace\\test\\src\\sounds\\alarm.au");
		try {
			audioClip = Applet.newAudioClip(audioFile.toURL());
		} catch (MalformedURLException e) {
			e.printStackTrace();
		}
	}

	public void play() {
		for (int i = 0; i < 100000; i++) {
			if (i % 1000 == 0) {
				System.out.println(i);
				audioClip.play();
				try {
					Thread.sleep(2000);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			}
		}
	}

	public static void main(String args[]) {
		SoundPlaySimp sps = new SoundPlaySimp();
		sps.init();
		sps.play();
	}
}
